<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>快速登记</title>
    <link href="../../layuiadmin/js/adm/css/bootstrap.css" rel="stylesheet">
    <script src="../../layuiadmin/js/adm/js/vue.js"></script>
    <script src="../../layuiadmin/js/adm/js/vue-resource.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.min.js"></script>
    <script src="../../layuiadmin/js/adm/js/bootstrap.js"></script>
    <script src="../../layuiadmin/js/adm/js/getUrlParam.js"></script>
    <script src="../../layuiadmin/js/adm/js/date.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui@1.4/lib/theme-default/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui@1.4/lib/index.js"></script>
    <script src="../../layuiadmin/js/adm/js/jquery.cookie.js"></script>

    
</head>
<body>
    <div id="app" style="margin: 10px 5%">
        <form class="form-inline">
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#navregister" aria-controls="navregister" role="tab" data-toggle="tab">发件管理</a></li>
                    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">收件管理</a></li>
                </ul>    
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="navregister"> <!--  发件管理 -->
                        <div class="row" style="margin-top: 20px">
                            <div class="col-md-12">
                                <input type="text"  class="form-control" v-model="rname" placeholder="收件人/领件人">&nbsp;
                                <select  class="form-control" v-model="mcompany">
                                    <option :value="-1" selected="selected">选择快递公司</option>
                                    <option v-for="item in company" :value="item.companyId">{{item.companyName}}</option>
                                </select>&nbsp;
                                <select  class="form-control" v-model="mespress" >
                                    <option :value="-1">选择快件类型</option>
                                    <option v-for="item in espress" :value="item.espressId">{{item.espressName}}</option>
                                </select>&nbsp;
                                <select  class="form-control" v-model="state">
                                    <option value="-1">领取状态</option>
                                    <option value="Y">已领件</option>
                                    <option value="N">未领件</option>
                                </select>&nbsp;&nbsp;
                                <label>日期:</label>
                                <input type="date" v-model="kdate" class="form-control">&nbsp;至
                                <input type="date" v-model="jdate" class="form-control">&nbsp;
                                <select class="form-control" v-model="judge">
                                    <option :value="1">根据收件日期</option>
                                    <option :value="2">根据领件日期</option>
                                </select>&nbsp;<br><br>
                                <input type="button" class="btn btn-primary" @click="postfurry()" value="检索">&nbsp;&nbsp;&nbsp;
                                <input type="button" class="btn btn-default" @click="postinsert()" value="添加收件">
                            </div>
                        </div>
          
                        <div class="row" style="margin-top: 20px">
                            <table class="table table-condensed table-hover">
                                <thead>
                                    <tr>
                                        <th>收件人</th>
                                        <th>收件日期</th>
                                        <th>案号</th>
                                        <th>快递公司</th>
                                        <th>快递类型</th>
                                        <th>快递费</th>
                                        <th>领件人</th>
                                        <th>领件状态</th>
                                        <th>领件时间</th>
                                        <th>备注说明</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-for="item in register">
                                        <td>{{item.empId.empName}}</td>
                                        <td>{{item.receipt}}</td>
                                        <td v-if="item.caseId!=null&&item.caseId!=''">{{item.caseId.caseId}}</td>
                                        <td v-if="item.caseId==null||item.caseId==''"></td>
                                        <td>{{item.companyId.companyName}}</td>
                                        <td>{{item.espressId.espressName}}</td>
                                        <td>{{item.cost}}</td>
                                        <td v-if="item.lempId==null||item.lempId==''"></td>
                                        <td v-if="item.lempId!=null&&item.lempId!=''">{{item.lempId.empName}}</td> 
                                        <td v-if="item.state=='Y'">已领件</td>
                                        <td v-if="item.state=='N'">未领件</td>
                                        <td>{{item.drawTime}}</td>
                                        <td>{{item.remark}}</td>
                                        <td>
                                            <div class="dropdown">
                                                <button class="btn btn-default dropdown-toggle btn-sm" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                    更多
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                                    <li><a href="#" @click="postquery(item.registerId)">查看</a></li>
                                                    <li><a href="#">删除</a></li>
                                                    <li><a href="#" @click="postupdate(item.registerId)">修改</a></li>
                                                </ul>
                                                </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>   
                    </div>

                      <!-- -------------------------------------分割线------------------------------------------------ -->
                    <div role="tabpanel" class="tab-pane" id="profile">
                        <div class="row" style="margin-top: 20px">
                            <div class="col-xs-12">
                                <input type="text" v-model="dname" class="form-control" placeholder="发件人/收件人">
                                <select  class="form-control" v-model="dcompany">
                                    <option :value="-1">选择快递公司</option>
                                    <option v-for="item in company" :value="item.companyId">{{item.companyName}}</option>
                                </select>&nbsp;
                                <select  class="form-control" v-model="despress">
                                    <option :value="-1">选择快件类型</option>
                                    <option v-for="item in espress" :value="item.espressId">{{item.espressName}}</option>
                                </select>&nbsp;
                                <label>日期:</label>
                                <input type="date" v-model="dkdate" class="form-control">&nbsp;至
                                <input type="date" v-model="djdate"  class="form-control">&nbsp;
                                <input type="button" class="btn btn-primary" @click="dispatchfurry()" value="检索">&nbsp;&nbsp;&nbsp;
                                <input type="button" class="btn btn-default" @click="dispatchtj()"  value="添加发件">
                            </div>
                            
                        </div>
                        <div class="row"  style="margin-top: 20px">
                            <table class="table table-condensed table-hover">
                                <thead>
                                    <tr>
                                        <th>发件人</th>
                                        <th>发件日期</th>
                                        <th>案号</th>
                                        <th>发件方式</th>
                                        <th>快件类型</th>
                                        <th>快递单号</th>
                                        <th>快递费</th>
                                        <th>收件人</th>
                                        <th>收件单位</th>
                                        <th>备注说明</th>
                                        <th>操作</th>
                                       
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr v-for="item in dispatch">
                                        <td>{{item.empId.empName}}</td>
                                        <td>{{item.taketime}}</td>
                                        <td v-if="item.caseId!=null&&item.caseId!=''">{{item.caseId.caseId}}</td>
                                        <td v-if="item.caseId==null||item.caseId==''"></td>
                                        <td>{{item.companyId.companyName}}</td>
                                        <td>{{item.espressId.espressName}}</td>
                                        <td>{{item.numbers}}</td>
                                        <td>{{item.cost}}</td>
                                        <td>{{item.recipients}}</td>
                                        <td>{{item.addressee}}</td>
                                        <td>{{item.remark}}</td>
                                        <td>
                                            <div class="dropdown">
                                                <button class="btn btn-default dropdown-toggle btn-sm" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                                                    更多
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
                                                    <li><a href="#" @click="dispatchselect(item.dispatchId)">查看</a></li>
                                                    <li><a href="#" @click="disdelete(item.dispatchId)">删除</a></li>
                                                    <li><a href="#" @click="dispatchupdate(item.dispatchId)">修改</a></li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
        </form>
    </div>
    

    <script>
          var vm=new Vue({
            el:'#app',
            data:{
                register:[

                ],
                company:[

                ],
                espress:[
                    
                ],
                mcompany:"-1",
                mespress:"-1",
                state:"-1",
                kdate:"",
                jdate:"",
                judge:"1",
                rname:"",
                //发件的------------------------------------
                dispatch:[],
                dkdate:"",
                djdate:"",
                dcompany:"-1",
                despress:"-1",
                dname:""
            },
            methods: {
                postupdate(id){
                    window.location.href="admRegisterupdate.html?id="+id;
                },
                postquery(id){
                    window.location.href="admRegisterquery.html?id="+id;
                },
                postinfo(){
                    this.$http.post('http://localhost:8080/register/listall',{},{emulateJSON:true}).then(result =>{
                     var dat=eval("("+result.body+")")
                     if(dat!=null&&dat!=""){
                        this.register=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.register.push(dat[i])
                        }
                     }else{
                         alert("获取失败")
                     }
                    })
                },
                postcompany(){
                    this.$http.post('http://localhost:8080/register/company',{},{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        if(dat!=null&&dat!=""){
                            this.company=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.company.push(dat[i])
                            }
                        }else{
                            alert("获取失败")
                        }
                    })
                },
                postespress(){
                    this.$http.post('http://localhost:8080/register/espress',{},{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        if(dat!=null&&dat!=""){
                            this.espress=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.espress.push(dat[i])
                            }
                        }else{
                            alert("获取失败")
                        }
                    })
                },
                postfurry(){
                    this.$http.post('http://localhost:8080/register/furry',
                    {   
                        "rname":this.rname,
                        "mcompany":this.mcompany,
                        "mespress":this.mespress,
                        "state":this.state,
                        "kdate":this.kdate,
                        "jdate":this.jdate,
                        "judge":this.judge
                    },{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                            this.register=new Array()   //每次重新new一个list集合给定义的list集合
                            for(var i=0;i<dat.length;i++){
                                this.register.push(dat[i])
                            }
                       
                    })
                },
                postinsert(){
                    location.href="admRegisterinsert.html";
                },

                //发件的-------------------------
                postdispatch(){
                    this.$http.post('http://localhost:8080/register/dispatch',{},{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        this.dispatch=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.dispatch.push(dat[i])
                        }
                    })
                },
                dispatchfurry(){  //模糊查询
                    this.$http.post('http://localhost:8080/register/dispatchfurry',{ 
                        "dname":this.dname,
                        "dkdate":this.dkdate,
                        "djdate":this.djdate,
                        "dcompany":this.dcompany,
                        "despress":this.despress
                    },{emulateJSON:true}).then(result =>{
                        var dat=eval("("+result.body+")")
                        this.dispatch=new Array()   //每次重新new一个list集合给定义的list集合
                        for(var i=0;i<dat.length;i++){
                            this.dispatch.push(dat[i])
                        }
                    })
                },
                dispatchselect(id){         //查看跳转
                    window.location.href="admDispatchquery.html?id="+id;
                },
                dispatchupdate(id){
                    window.location.href="admDispatchupdate.html?id="+id;
                },
                dispatchtj(){
                    location.href="admDispatchinsert.html"
                },
                disdelete(id){
                    this.http.post('http://localhost:8080/register/disdelete',{"id":id},{emulateJSON:true}).then(result =>{
                        if(result.body=='1'){
                            this.open2()
                            this.postdispatch()
                        }
                    })
                },
                open2() {
                    this.$message({
                        showClose: true,
                        message: '删除成功',
                        type: 'success'
                    });
                }
            },
            created () {
                this.postinfo()
                this.postespress()
                this.postcompany()
                //--------------发件
                this.postdispatch()
            }
        })      
    </script>

</body>
</html>